
#include "cVector.h"

float cVector2D::getX() { return m_x; }
float cVector2D::getY() { return m_y; }
float cVector2D::length() { return sqrt(m_x*m_x + m_y*m_y); }

void cVector2D::setX(float x) { m_x = x; }
void cVector2D::setY(float y) { m_y = y; }

cVector2D cVector2D::operator+(const cVector2D vector) const
{
	return cVector2D(m_x + vector.m_x, m_y + vector.m_y);
}

cVector2D cVector2D::operator-(const cVector2D vector) const
{
	return cVector2D(m_x - vector.m_x, m_y - vector.m_y);
}

cVector2D cVector2D::operator*(float scalar)
{
	return cVector2D(m_x*scalar, m_y*scalar);
}

cVector2D cVector2D::normalize()
{
	float  l = length();
	return cVector2D(m_x / l, m_y / l);
}
